package a_erfenchazhao.lianxiti;

/**
 * @ClassName AiChiXiangJiaoDeKeKe
 * @Description
 * @Author Zhang Li Tao
 * @Date 2024/3/18
 * @Version 1.0
 **/
public class AiChiXiangJiaoDeKeKe {
    public static void main(String[] args) {
        int[] piles = {3, 6, 7, 11};
        int h = 8;

        System.out.println(minEatingSpeed(piles, h));
    }

    /**
     * 示例 1：
     *
     * 输入：piles = [3,6,7,11], h = 8
     * 输出：4
     * 示例 2：
     *
     * 输入：piles = [30,11,23,4,20], h = 5
     * 输出：30
     * 示例 3：
     *
     * 输入：piles = [30,11,23,4,20], h = 6
     * 输出：23
     */
    public static int minEatingSpeed(int[] piles, int h) {
        // 计算数组中所有元素之和
        int total = 0;
        for (int pile : piles) {
            total = pile + total;
        }

        // 以h为底 递增数组
        int[] hArray = new int[total / h + 2];

        for (int i = 0; i < total / h + 2; i++) {
            hArray[i] = i * h;
        }

        // [0, 8, 16, 24, 32]
        int leftIndex = 0;
        int rightIndex = hArray.length - 1;

        while (leftIndex <= rightIndex) {
            int middleIndex = (leftIndex + rightIndex) >>> 1;

        }

        return -1;
    }
}
